<?php
// +----------------------------------------------------------------------
// | WoShiMaiJia Projcet
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <517577550@qq.com>
// +----------------------------------------------------------------------
/**
 * 网址
 * @author xinqiyang
 * @date   2010-6-8
 *
 */

class UrlModel extends MetaModel
{


	protected $_validate  = array(
	
//	array ('domain','url','域名不能为空或输入不正确',1,'',1),
//	array('domain','','本站已被其他人录入,谢谢您了',1,'unique',1),
	array ('title','require','名称不能为空',1,'',1),
	//array ('im','require','IM不能为空',1,'',1),
	array ('category_id','require','链接类型不能为空',1,'',1),
		
	);


	protected $_auto = array(
	array ('status','1'),
	array ('user_id','userID',1,'function'),
	array ('createtime','time',1,'function'),
	);
	
	
	public function getUrls($arr)
	{
		return  $this->query("select sz_url.id,sz_url.title,sz_url.category_id,sz_url.user_id,sz_url.tags,sz_url.goodnum,sz_url.domain,sz_url.desc,sz_user.cnname,sz_url.buynum,sz_url.domain,sz_url.gonum,sz_url.im,sz_image.url,sz_image.model,sz_image.filename from sz_url,sz_image,sz_user where sz_url.image_id=sz_image.id and sz_url.user_id = sz_user.id and sz_url.id in ".strin($arr).'   ORDER BY  `sz_url`.`sequence` DESC');

	}
	
	public function newgetUrls($arr)
	{
		return  $this->query("select distinct sz_url.id,sz_url.title,sz_url.category_id,sz_url.user_id,sz_url.tags,sz_url.goodnum,sz_url.desc,sz_user.cnname,sz_url.buynum,sz_url.domain,sz_url.gonum,sz_url.im,sz_image.url,sz_image.model,sz_image.filename from sz_url,sz_image,sz_user where sz_url.image_id=sz_image.id and sz_url.user_id = sz_user.id and sz_url.id in ".$arr.'   ORDER BY  `sz_url`.`sequence` DESC');

	}
	/**
	 * 获取推荐网址用户还去过的其他地方,使用rand()防止重复
	 * @param unknown_type $arr
	 */
	public function getuserUrls($arr)
	{
		return  $this->query("select distinct sz_url.id,sz_url.title,sz_url.category_id,sz_url.user_id,sz_url.tags,sz_url.goodnum,sz_url.desc,sz_user.cnname,sz_url.buynum,sz_url.domain,sz_url.gonum,sz_url.im,sz_image.url,sz_image.model,sz_image.filename from sz_url,sz_image,sz_user where sz_url.image_id=sz_image.id and sz_url.user_id = sz_user.id and sz_url.user_id in ".$arr.'   ORDER BY  `sz_url`.`sequence` DESC,rand() limit 0,18');

	}
}

?>